<template>
    <div class="login-page">
  <UserForm @onSumbit="onSubmit"/>
    </div>

  </template>

<script>
import { LoginAPI } from '@/api/user'
import UserForm from '@/components/UserForm.vue'
import { setToken } from '@/utils/storage'
export default {
  name: 'Register-Page',
  components: {
    UserForm
  },
  data () {
    return {
      username: '',
      password: ''
    }
  },
  methods: {
    async  onSubmit (values) {
      console.log(values)

      const res = await LoginAPI(values)
      console.log('res  ----->  ', res)
      setToken(res.data.token)
      this.$toast('登录成功')
      this.$router.push('/')
    }
  }
}
</script>

  <style lang="less" scoped>
    .link {
      color: #069;
      font-size: 12px;
      padding-right: 20px;
      float: right;
    }
  </style>
